package UniqueInfoboxAttributes;

import zclTool.*;

import java.io.*;

import java.util.*;

public class PickSomeForGoogle {

	/**
	 * @param args
	 */

	static WordNetJwi wnjwi;
	public static String splitByOf(String a){
		boolean tag = true;
		if(a.equals("footballhof")){
			System.out.print("");
		}
		String []s = a.split("of");
		if(a.contains("of")){
			for(int i = 0;i<s.length;i++){
				HashSet<String>temp = wnjwi.getSynonyms(s[i]);
				if(!wnjwi.isDictWord(s[i])){
					tag = false;
				}
			}
		}else{
			tag = false;
		}
		if(tag){
			return a.replace("of","_of_");
		}else{
			return null;
		}
	}
	
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub

		DelimitedReader dr = new DelimitedReader("attributes");
		OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(
				"attNames"));
		OutputStreamWriter osw2 = new OutputStreamWriter(new FileOutputStream(
		"forGoogle"));
		wnjwi = new WordNetJwi();
		String[] line;
		int ln = 0;
		while ((line = dr.read()) != null ) {
			ln++;
			String attname = line[2].toLowerCase();
			if(attname.equals("Died")){
				System.out.print("");
			}
			attname=attname.replaceAll("[0-9]", " ");
			String whatItIs = attname;
			if (attname.contains("_") || attname.contains(" ") || attname.contains("-")) {
				osw.write(line[1] + "@" + line[2] +"\t"+whatItIs+ "\n");
			}else if(wnjwi.isDictWord(attname)){
				osw.write(line[1] + "@" + line[2] +"\t"+whatItIs+ "\n");
			}else if((whatItIs = splitByOf(attname))!=null){
				osw.write(line[1] + "@" + line[2] + "\t"+whatItIs+"\n");
			}else {
				//Thread.sleep(3000);
				System.out.println(line[1] + "\t" + line[2]);
				osw2.write(line[1] + "\t" + line[2] + "\n");
//				String[] b = GSpellCheck.doSpellCheck(attname);
//
//				osw.write(line[1] + "\t" + line[2] + "\t");
//				for (String x : b) {
//					osw.write(x.replace("\\s", "_") + "\t");
//				}
//
//				System.out.println(line[1] + "\t" + line[2] + "\t" + b[0]);
//				osw.write("\n");
			}
			
		}
		dr.close();
		osw.close();
		osw2.close();
	}

}
